<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/4/10 0010
 * Time: 21:06
 */
//echo '父进程ID' . posix_getpid();
$key = ftok(__DIR__, 'u');
for ($i = 0; $i < 3; $i++) {
    $process = new Swoole\Process(function (Swoole\Process $process) {
        //子进程空间
        echo '子进程' . $process->pop() . PHP_EOL;
//        $process->push('hello 主进程');
    });
    $process->useQueue(1, 2 | swoole_process::IPC_NOWAIT);

    $process->start();
    $pid = $process->pid;
    $process->push('hello 子进程');
//    echo '主进程打印的消息' . $process->pop() . PHP_EOL;
}
while ($res = Swoole\Process::wait()) {

    var_dump($res);
}